#include "HiKernel/HiObject.h"

int HiObject::m_siIndex = 0;

HiObject::HiObject(const std::string _name) : m_sName(_name)
{
	 m_iIndex = m_siIndex++;
}

	
HiObject::~HiObject() 
{
}


HiObject*
HiObject::Find(std::vector<HiObject*> &_list, const std::string& _name)
{
	for( std::vector<HiObject*>::iterator i=_list.begin();i!=_list.end();i++)
		if ( !(*i)->GetName().compare(_name) )
			return (*i);
}
HiObject*
HiObject::Find(std::vector<HiObject*> &_list, int id)
{
	for( std::vector<HiObject*>::iterator i=_list.begin();i!=_list.end();i++)
		if ( (*i)->GetIndex() == id)
			return (*i);
	return 0;
}

const std::string 
HiObject::GetName()                                             
{ 
	return m_sName.empty() ? "NULL_NAME": m_sName; 
}

void 
HiObject::SetName(const std::string& _name)                  
{ 
	m_sName = _name; 
}

int 
HiObject::GetIndex()                                                                  
{ 
	return m_iIndex;  
}



bool HiObject::HandleMessage(const Telegram &msg)
{
	return true;
}